package Boke2;

public class OnlyWaitTimeout {
    //创建两个用于线程加锁的对象
    public static Object loker1=new Object();
    public static Object loker2=new Object();

    public static void main(String[] args) {
        //新线程t1
        Thread t1=new Thread(()->{
            System.out.println("t1线程开始 调用wait(long timeout)之前");
            //让t1线程进入阻塞等待
            synchronized (loker1){
                try {
                    long begin=System.currentTimeMillis();
                    //让被加锁的loker1对象进入阻塞等待
                    loker1.wait(5000);
                    long end=System.currentTimeMillis();
                    System.out.println("阻塞等待大概时间"+(end-begin));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("t1线程结束 wait(long timeout)阻塞等待解除");
        });
        t1.start();
    }
}
